/* GUI CONVERTED from reoptr7a.p (converter v1.75) Sat Aug 12 23:07:42 2000 */
/* reoptr7a.p - SETUP OPERATION TRANSACTION BY PART (REPETITIVE) SUBROUTINE  */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                       */
/* All rights reserved worldwide.  This is an unpublished work.              */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                        */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                      */
/* REVISION: 7.3      LAST MODIFIED: 02/10/93   BY: emb *G689*/
/* REVISION: 7.3      LAST MODIFIED: 03/30/93   BY: emb *G882*/
/* REVISION: 7.3      LAST MODIFIED: 12/30/94   BY: cpp *FT95*/


/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan        */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan        */
/* REVISION: 9.1      LAST MODIFIED: 10/25/99   BY: *N002* Bill Gates        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb               */

/*N002*/  {mfdeclre.i}
          {gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE reoptr7a_p_1 "Elapsed or Stop Time"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoptr7a_p_2 "Start Time"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

     define shared variable wr_recno as recid.
     define shared variable wc_recno as recid.
     define shared variable op_recno as recid.

     define variable yn like mfc_logical.

     define variable start_setup as character format "99:99:XX"
        label {&reoptr7a_p_2}.
     define variable start_run like start_setup.
     define variable stop_setup like start_setup
        label {&reoptr7a_p_1}.
     define variable stop_run like stop_setup.
     define variable date_change as integer.
     define variable elapse as decimal format ">>>>>>>>.999".

     define variable i as integer.
     define variable j as integer.

     define variable last_date like op_date.
/*G882*  define variable input_total as decimal format "->>9.9<<"
        label "Input Total". */
/*G882*/ define shared variable input_total as decimal format "->>9.9<<".
/*G882*  define variable control_total like input_total label "Control Total".*/
/*G882*/ define shared variable control_total like input_total.
     define variable shift like op_shift.
/*G689*  define shared variable site like rps_site. */
/*G689*/ define shared variable site like rps_site no-undo.
/*G689*  define shared variable prline like rps_line. */
/*G689*/ define shared variable prline like rps_line no-undo.

     define shared variable part like op_part no-undo.
     define shared variable op like ps_op no-undo.
     define shared variable bom_code as character format "x(18)".
     define shared variable routing as character format "x(18)".

     define shared frame a.
     define shared frame b.

/*N002*/ define shared variable h_wiplottrace_procs as handle no-undo.
/*N002*/ define shared variable h_wiplottrace_funcs as handle no-undo.
/*N002*/ {wlfnc.i} /* FUNCTION FORWARD DECLARATIONS */
/*N002*/ {wlcon.i} /* CONSTANTS DEFINITIONS         */

     /* DISPLAY TITLE */
/*N002**  {mfdeclre.i}  */

     
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
        
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
op_emp colon 9
        ad_name no-label no-attr-space
        input_total colon 68
        skip
        last_date
        shift
        site
        control_total colon 68
      SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



     /* SET EXTERNAL LABELS */
     setFrameLabels(frame a:handle).

     FORM /*GUI*/ 
        
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
part           colon 22 pt_desc1       no-label
        op             colon 22 ro_desc        no-label
        prline         colon 22 ln_desc        no-label
        routing        colon 22 bom_code
        op_wkctr       colon 22 op_mch wc_desc no-label no-attr-space
        op_dept        colon 22 dpt_desc no-label no-attr-space
                             start_run      colon 65
        op_act_setup   colon 22                       stop_run      colon 65
        op_earn        colon 22 ea_desc no-label no-attr-space
/*FT95*     op_trnbr       colon 22 */
/*FT95*/    op_trnbr       colon 22 format ">>>>>>>9"
        op_wo_lot      colon 41
      SKIP(.4)  /*GUI*/
with frame b side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-b-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
 RECT-FRAME-LABEL:HIDDEN in frame b = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame b =
  FRAME b:HEIGHT-PIXELS - RECT-FRAME:Y in frame b - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME b = FRAME b:WIDTH-CHARS - .5.  /*GUI*/


     /* SET EXTERNAL LABELS */
     setFrameLabels(frame b:handle).

     find op_hist exclusive-lock where recid(op_hist) = op_recno.

/*N002*/ if is_wiplottrace_enabled() then do:
/*N002*/    run init_labor_vars in h_wiplottrace_procs.
/*N002*/ end.

          set_ophist:
          do on error undo, retry with frame b:
/*GUI*/ if global-beam-me-up then undo, leave.

             display input_total with frame a.

             set op_wkctr op_mch editing:
            {mfnp.i wc_mstr op_wkctr wc_wkctr
             op_wkctr wc_wkctr wc_wkctr}

            if recno <> ? then
            display wc_wkctr @ op_wkctr
            wc_mch @ op_mch wc_desc.
             end.

             find wc_mstr no-lock where wc_wkctr = op_wkctr
             and wc_mch = op_mch no-error.
             if not available wc_mstr then do:
            {mfmsg.i 519 3} /* Work center does not exist */
            undo, retry.
             end.

             display wc_desc wc_dept @ op_dept.
             find dpt_mstr no-lock where dpt_dept = wc_dept no-error.
             if available dpt_mstr
             then display dpt_desc.
             else display " " @ dpt_desc.

             do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

            set op_dept op_act_setup op_earn editing:
               if frame-field = "op_dept" then do:
                  {mfnp.i dpt_mstr op_dept dpt_dept
                   op_dept op_dept dpt_dept}
                  if recno <> ? then
                 display dpt_dept @ op_dept dpt_desc.
               end.
               else if frame-field = "op_earn" then do:
                  {mfnp.i ea_mstr op_earn ea_earn
                   op_earn ea_earn ea_earn}
                  if recno <> ? then
                 display ea_earn @ op_earn ea_desc.
               end.
               else do:
                  readkey.
                  apply lastkey.
               end.
            end.

            find dpt_mstr no-lock where dpt_dept = op_dept
            no-error.
            if not available dpt_mstr then do:
               next-prompt op_dept.
               {mfmsg.i 532 3} /* Department does not exist */
               undo, retry.
            end.

            display dpt_desc.

            if op_earn > "" then do:
               find ea_mstr where ea_earn = op_earn
               no-lock no-error.
               if not available ea_mstr then do:
                  {mfmsg.i 4025 3} /* Invalid earnings code */
                  next-prompt op_earn.
                  undo, retry.
               end.

               display ea_desc.
            end.
            else display " " @ ea_desc.
             end.
/*GUI*/ if global-beam-me-up then undo, leave.


             if op_act_setup = 0 then
             do on error undo, retry with frame b:
/*GUI*/ if global-beam-me-up then undo, leave.

            set start_run stop_run.
            {mfctime.i start_run stop_run}
            op_act_setup = elapse.
            display op_act_setup.
             end.
/*GUI*/ if global-beam-me-up then undo, leave.


             elapse = op_act_setup.

             input_total = input_total + op_act_setup.

             display input_total with frame a.

/*N002*/     if is_wiplottrace_enabled()
/*N002*/     and is_operation_queue_lot_controlled
/*N002*/         (op_wo_lot, op_wo_op, OUTPUT_QUEUE)
/*N002*/     then do:
/*N002*/         view frame a.
/*N002*/         view frame b.
/*N002*/         pause 0.
/*N002*/         run get_labor_wip_lots_from_user in h_wiplottrace_procs
/*N002*/             (input op_part, op_wo_op).
/*N002*/     end.

             yn = yes.
             {mfmsg01.i 12 1 yn}
             if yn = no then undo, retry.
          end.
/*GUI*/ if global-beam-me-up then undo, leave.


/*N002*/  if is_wiplottrace_enabled()
/*N002*/  and is_operation_queue_lot_controlled
/*N002*/      (op_wo_lot, op_wo_op, OUTPUT_QUEUE)
/*N002*/  then do:
/*N002*/      run labor_create_trace_records in h_wiplottrace_procs
/*N002*/          (input op_trnbr, input op_wo_lot, input op_wo_op).
/*N002*/  end.
